				#####################################
				# REPLICATION MATERIAL for: 
				# Di Leo, R., Dinas, E., and Meiske, B. (2025), "Berlinguer I Love You (Still): the Downstream Effects of Expressive Voting
				#####################################


/*
*** Note: replicators should add to the local ado folder (identify it using the command "sysdir"): 

ado files to include in the Stata "ado" directory: 	"DCdensity.ado" "rddisttestk.ado"  	
(typically following a path "ado/plus/initial of the package", use command "sysdir" to identify it. Note that Stata must be restarted to incorporate the files change)	


	a. "DCdensity.ado" used to compute the density test (also available here: https://eml.berkeley.edu/~jmccrary/DCdensity/) 
		Developed by Justin McCrary. 
		See: McCrary, Justin. "Manipulation of the running variable in the regression discontinuity design: A density test." Journal of econometrics 142.2 (2008): 698-714.

	b. "rddisttestk.ado" used to compute the density test (also available here: https://economics.byu.edu/frandsen/Pages/Software.aspx) 
		Developed by Brigham R. Fradsen.
*/



/*
*** Note: replicators must install the following packages (by uncommenting this section)

net install rdrobust, from(https://raw.githubusercontent.com/rdpackages/rdrobust/master/stata) replace

ssc install ebalance, replace
ssc install center, replace
ssc install estout, replace
ssc install grstyle, replace
ssc install coefplot, replace
ssc install rddsga, replace
ssc install kountry, replace
ssc install iscogen, replace 
ssc install rangestat, replace
ssc install rangejoin, replace 
ssc install nearmrg, replace

ssc install palettes
ssc install colrspace
*/



clear all
set graphics off


Note: replicators should set up directories to open data and save tables and figures 
global root ""
cd "$root"

mkdir "$root\Main"
mkdir "$root\Main\Figures"
global figures "$root\Main\Figures"

mkdir "$root\Main\Tables"
global tables "$root\Main\Tables"




use "Elezioni_final_09_2025", clear


##############
## MAIN PAPER
##############

***FIGURE 6a
	
est clear	
reg berlinguer_8479 centrale , cluster(prov)
est sto a1
loc n_a1=e(N)

reg berlinguer_8379 centrale , cluster(prov)
est sto b1
loc n_b1=e(N)

reg berlinguer_7976 centrale , cluster(prov)
est sto c1
loc n_c1=e(N)

reg berlinguer_7672 centrale , cluster(prov)
est sto d1
loc n_d1=e(N)

reg berlinguer_7268 centrale , cluster(prov)
est sto e1
loc n_e1=e(N)

*set graphics on
coefplot ///                
                (a1,  offset(0)   keep(centrale) rename(centrale = "1984e-1979e")                         label(2 day) msymbol(circle)  mcolor(black) ciopts(lcolor(black black))) ///
                (b1,  offset(0)  keep(centrale) rename(centrale = "1983n-1979n")                         label(2 day) msymbol(circle)  mcolor(black) ciopts(lcolor(black black))) ///
                (c1,  offset(0)   keep(centrale) rename(centrale = "1979n-1976n")                         label(2 day) msymbol(circle)  mcolor(black) ciopts(lcolor(black black))) ///
                (d1,  offset(0)   keep(centrale) rename(centrale = "1976n-1972n")                         label(2 day) msymbol(circle)  mcolor(black) ciopts(lcolor(black black))) ///
                (e1,  offset(0)   keep(centrale) rename(centrale = "1972n-1968n")                         label(2 day) msymbol(circle)  mcolor(black) ciopts(lcolor(black black))) ///
                , levels(95 90) xline(0, lpattern(dash) lcolor(orange)) xtitle("Coefficient Estimate", size(small)) subtitle("Change in PCI's Municipal Vote Share") xlabel(,labsize(small)) ///
				groups("1984e-1979e" = "N = `n_a1'" "1983n-1979n" = "N = `n_b1'"  "1979n-1976n" = "N = `n_c1'" "1976n-1972n" = "N = `n_d1'" "1972n-1968n" = "N = `n_e1'", labsize(vsmall)) ///
				grid(between glpattern(dash) glwidth(*2) glcolor(white) nogextend) ///
				plotregion(lc(black)) ///
				yscale(alt axis(2)) ///
				legend(order(3 "Centrale District") pos(6) row(1)) graphregion(col(white)) bgcol(white)

					
                graph export "$figures/Figure_6a.pdf", as(pdf) replace
                est clear	


***FIGURE 6b
	
est clear	
reg berlinguer_8479 centrale sh_pci_p76 C.berlinguer_8379##C.berlinguer_8379##C.berlinguer_8379 , cluster(prov)
est sto a1
loc n_a1=e(N)

reg craxi_8479 centrale sh_psi_p76 C.craxi_8379##C.craxi_8379##C.craxi_8379 , cluster(prov)
est sto b1
loc n_b1=e(N)

reg andreotti_8479 centrale sh_dc_p76 C.andreotti_8379##C.andreotti_8379##C.andreotti_8379 , cluster(prov)
est sto c1
loc n_c1=e(N)

reg almirante_8479 centrale sh_msi_p76 C.almirante_8379##C.almirante_8379##C.almirante_8379 , cluster(prov)
est sto d1
loc n_d1=e(N)

reg turnout_8479 centrale turnout_p76 C.turnout_8379##C.turnout_8379##C.turnout_8379 , cluster(prov)
est sto e1
loc n_e1=e(N)

*set graphics on
coefplot ///                
                (a1,  offset(0)   keep(centrale) rename(centrale = "PCI")                         label(2 day) msymbol(circle)  mcolor(black) ciopts(lcolor(black black))) ///
                (b1,  offset(0)   keep(centrale) rename(centrale = "PSI")                         label(2 day) msymbol(circle)  mcolor(black) ciopts(lcolor(black black))) ///
                (c1,  offset(0)   keep(centrale) rename(centrale = "DC")                         label(2 day) msymbol(circle)  mcolor(black) ciopts(lcolor(black black))) ///
                (d1,  offset(0)   keep(centrale) rename(centrale = "MSI")                         label(2 day) msymbol(circle)  mcolor(black) ciopts(lcolor(black black))) ///
                (e1,  offset(0)   keep(centrale) rename(centrale = "Turnout")                         label(2 day) msymbol(circle)  mcolor(black) ciopts(lcolor(black black))) ///
                , levels(95 90) xline(0, lpattern(dash) lcolor(orange)) xtitle("Coefficient Estimate", size(small)) subtitle("Change in Municipal Vote Share and Turnout (1984e-1979e)") xlabel(#3,labsize(small)) ///
				groups("PCI" = "N = `n_a1'" "PSI" = "N = `n_b1'"  "DC" = "N = `n_c1'" "MSI" = "N = `n_d1'" "Turnout" = "N = `n_e1'", labsize(vsmall)) ///
				grid(between glpattern(dash) glwidth(*2) glcolor(white) nogextend) ///
				plotregion(lc(black)) ///
				yscale(alt axis(2)) ///
				legend(order(3 "Centrale District") pos(6) row(1)) graphregion(col(white)) bgcol(white)

					
                graph export "$figures/Figure_6b.pdf", as(pdf) replace
                est clear		


***FIGURE 7

gen first=berlinguer_8379 
gen second=berlinguer_8379*berlinguer_8379
gen third= berlinguer_8379*berlinguer_8379*berlinguer_8379 

global pcomp "berlinguer_8479"
foreach y of global pcomp {

	local i=1
	matrix A_`y' = J(9,7,0)
	
	foreach b of numlist 20(10)100 {

		local i=`i'+1
		matrix A_`y'[(`b')-(9*`i'+1),1] = `b'

		rdrobust `y' distanceNORTH_km if descrregione!="SICILIA" & descrregione!="SARDEGNA" , p(1) c(0) h(`b') covs(sh_pci_p76 first second third)

		matrix A_`y'[(`b')-(9*`i'+1),2] = e(tau_bc)
		matrix A_`y'[(`b')-(9*`i'+1),3] = e(tau_bc) - 1.96 * e(se_tau_cl)
		matrix A_`y'[(`b')-(9*`i'+1),4] = e(tau_bc) + 1.96 * e(se_tau_cl)
		matrix A_`y'[(`b')-(9*`i'+1),5] = e(N_h_l) + e(N_h_r)
		matrix A_`y'[(`b')-(9*`i'+1),6] = e(tau_bc) - 1.96 * e(se_tau_rb)
		matrix A_`y'[(`b')-(9*`i'+1),7] = e(tau_bc) + 1.96 * e(se_tau_rb)
	}

		rdrobust `y' distanceNORTH_km if descrregione!="SICILIA" & descrregione!="SARDEGNA" , p(1) c(0) h(59) covs(sh_pci_p76 first second third)

		matrix A_`y'[9,1] = 59
		matrix A_`y'[9,2] = e(tau_bc)
		matrix A_`y'[9,3] = e(tau_bc) - 1.96 * e(se_tau_cl)
		matrix A_`y'[9,4] = e(tau_bc) + 1.96 * e(se_tau_cl)
		matrix A_`y'[9,5] = e(N_h_l) + e(N_h_r)
		matrix A_`y'[9,6] = e(tau_bc) - 1.96 * e(se_tau_rb)
		matrix A_`y'[9,7] = e(tau_bc) + 1.96 * e(se_tau_rb)
}

quietly foreach y of global pcomp {
	preserve
	svmat A_`y'
	twoway (scatter A_`y'2 A_`y'1 if A_`y'1!=60 , mcolor(black msize(small))) ///
		(scatter A_`y'2 A_`y'1 if A_`y'1==59 , mcolor(red msize(small))) ///
		(rcap A_`y'6 A_`y'7 A_`y'1 if A_`y'1!=60 , vertical lcolor(gray) lwidth(thin)) ///
		(rcap A_`y'6 A_`y'7 A_`y'1 if A_`y'1==59 , vertical lcolor(orange) lwidth(thin)) ///
		(rcap A_`y'3 A_`y'4 A_`y'1 if A_`y'1!=60 , vertical lcolor(black lwidth(thick))) ///
		(rcap A_`y'3 A_`y'4 A_`y'1  if A_`y'1==59 , vertical lcolor(red lwidth(thick))) , ///
		legend(off) graphregion(fcolor(white) lcolor(white)) ylab(, nogrid) ylabel(-0.01 0 0.01 0.02) xlabel(20 30 40 50 59 70 80 90 , nogrid) ///
		subtitle("Change in PCI's Municipal Vote Share (1984e-1979e)") ytitle("RD Estimate") xtitle("Bandwidth (Km from Northern Border)") legend(off) yline(0,lpattern(dash) lcolor(orange))
	graph save Graph "$figures\g_`y'.gph", replace
	restore
}

graph save Graph "$figures\Figure_7.gph", replace
graph export "$figures\Figure_7.pdf", replace
sleep 10
erase "$figures\Figure_7.gph" 
sleep 10
erase "$figures\g_berlinguer_8479.gph"



***TABLE 1 --> SEE DO FILE ITANES



***TABLE 2

est clear
global pcomp "sh_si_ref_1985 sh_pci_p87 sh_pci_e89 "

matrix RDROBUST_matrix = J(6,3,0)
matrix rownames RDROBUST_matrix = "Distance from Northern Border" "SE" "N." "Mean" "Bandwidth (in Km)" "p-value"
matrix colnames RDROBUST_matrix = "(1)" "(2)" "(3)"
local i=0
 foreach y of global pcomp{
		 foreach poly of numlist 1 {	
				local i=`i'+1

			rdrobust `y' distanceNORTH_km if descrregione!="SICILIA" & descrregione!="SARDEGNA" , p(`poly') c(0) covs(sh_pci_p76 first second third) all

			matrix RDROBUST_matrix[1,`i'] = e(tau_bc)
			matrix RDROBUST_matrix[2,`i'] = e(se_tau_rb)
			matrix RDROBUST_matrix[3,`i'] = e(N_h_l) + e(N_h_r)
			sum `y' if r>=-floor(e(h_l)) & r<=floor(e(h_l))
			matrix RDROBUST_matrix[4,`i'] = `r(mean)'
			matrix RDROBUST_matrix[5,`i'] = floor(e(h_l))
			matrix RDROBUST_matrix[6,`i'] = e(pv_rb)
	}
	
}

estout matrix(RDROBUST_matrix, fmt("3 3 0 3 0 3")) using "$tables\Table_2.tex", style(tex) replace starlevels(+ 0.1 * 0.05 ** 0.01 *** 0.001)
